import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:lcapp/config/const_config.dart';
import 'package:lcapp/model/toast/toast.dart';

class ZixunDetailSetSize extends StatefulWidget {
  final Function fontBlock;
  final double fontSize;
  const ZixunDetailSetSize({Key? key, required this.fontBlock, required this.fontSize}) : super(key: key);

  @override
  State<ZixunDetailSetSize> createState() => _ZixunDetailSetSizeState();
}

class _ZixunDetailSetSizeState extends State<ZixunDetailSetSize> {

  double sliderValue = 32.sp;

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    sliderValue = widget.fontSize;
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.only(left: 40.w,right: 40.w,bottom: ScreenUtil().bottomBarHeight+50.w,top: 50.w),
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.only(topLeft: Radius.circular(10.w),topRight: Radius.circular(10.w)),
      ),
      child: Column(
        mainAxisSize: MainAxisSize.min,
        mainAxisAlignment: MainAxisAlignment.end,
        children: [
          Container(
            child: Text('字体大小',style: TextStyle(
                fontSize: 34.sp,
                fontWeight: FontWeight.w500
            ),),
          ),
          Container(
            child: Row(
              children: [
                Text('A',style: TextStyle(
                    fontSize: 28.sp,
                    fontWeight: FontWeight.w500
                ),),
                Expanded(child: Container(
                  child: SliderTheme(
                    data: SliderThemeData(
                      trackHeight: 1,
                      activeTrackColor: defaultBarColor,
                      inactiveTrackColor: Color(0xffdddddd),
                      thumbColor: defaultBarColor,
                      thumbShape: RoundSliderThumbShape(enabledThumbRadius: 12.w,disabledThumbRadius: 12.w)
                    ),
                    child: Slider(
                      max: 46.sp,
                      min: 32.sp,
                      value: sliderValue,
                      onChanged: (value){
                        setState(() {
                          sliderValue = value;
                        });
                      },
                      onChangeEnd: (value){
                        if(widget.fontBlock!=null){
                          widget.fontBlock(sliderValue);
                        }
                      },
                    ),
                  ),
                )),
                Text('A',style: TextStyle(
                    fontSize: 38.sp,
                    fontWeight: FontWeight.w500
                ),),
              ],
            ),
          )
        ],
      ),
    );
  }
}
